<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-AAS.
 *
 * PHP-AAS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-AAS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-AAS; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-aas
 * @subpackage  users
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */

//require_once("aas/User");
//require_once("aas/Group");
//require_once("aas/Role");

/**
 * <p>Convenience base class for {@link User} implementations.</p>
 */

class AbstractUser { // implements User


    // ----------------------------------------------------- Instance Variables


    /**
     * The full name of this user.
     */
    protected $fullName = null;


    /**
     * The logon password of this user.
     */
    protected $password = null;


    /**
     * The logon username of this user.
     */
    protected $username = null;


    // ------------------------------------------------------------- Properties


    /**
     * Return the full name of this user.
     */
    public function getFullName() {

        return ($this->fullName);

    }


    /**
     * Set the full name of this user.
     *
     * @param $fullName The new full name
     */
    public function setFullName($fullName) {

        $this->fullName = $fullName;

    }


    /**
     * Return the set of {@link Group}s to which this user belongs.
     */
    public function getGroups();


    /**
     * Return the logon password of this user, optionally prefixed with the
     * identifier of an encoding scheme surrounded by curly braces, such as
     * <code>{md5}xxxxx</code>.
     */
    public function getPassword() {

        return ($this->password);

    }


    /**
     * Set the logon password of this user, optionally prefixed with the
     * identifier of an encoding scheme surrounded by curly braces, such as
     * <code>{md5}xxxxx</code>.
     *
     * @param password The new logon password
     */
    public function setPassword($password) {

        $this->password = $password;

    }


    /**
     * Return the set of {@link Role}s assigned specifically to this user.
     */
    public function getRoles();


    /**
     * Return the logon username of this user, which must be unique
     * within the scope of a {@link org.apache.catalina.UserDatabase}.
     */
    public function getUsername() {

        return ($this->username);

    }


    /**
     * Set the logon username of this user, which must be unique within
     * the scope of a {@link org.apache.catalina.UserDatabase}.
     *
     * @param username The new logon username
     */
    public function setUsername($username) {

        $this->username = username;

    }


    // --------------------------------------------------------- Public Methods


    /**
     * Add a new {@link Group} to those this user belongs to.
     *
     * @param group The new group
     */
    public function addGroup(Group $group);


    /**
     * Add a new {@link Role} to those assigned specifically to this user.
     *
     * @param role The new role
     */
    public function addRole(Role $role);


    /**
     * Is this user in the specified {@link Group}?
     *
     * @param group The group to check
     */
    public function isInGroup(Group $group);


    /**
     * Is this user specifically assigned the specified {@link Role}?  This
     * method does <strong>NOT</strong> check for roles inherited based on
     * {@link Group} membership.
     *
     * @param role The role to check
     */
    public function isInRole(Role $role);


    /**
     * Remove a {@link Group} from those this user belongs to.
     *
     * @param group The old group
     */
    public function removeGroup(Group $group);


    /**
     * Remove all {@link Group}s from those this user belongs to.
     */
    public function removeGroups();


    /**
     * Remove a {@link Role} from those assigned to this user.
     *
     * @param role The old role
     */
    public function removeRole(Role $role);


    /**
     * Remove all {@link Role}s from those assigned to this user.
     */
    public function removeRoles();


    // ------------------------------------------------------ Principal Methods


    /**
     * Make the principal name the same as the group name.
     */
    public function getName() {
        return ($this->getUsername());

    }


}
?>